<?php
namespace weixinpayApp;
include 'demo/h5pay.php';
class wxh5{
    //$data 金额和订单号
    public function wxh5Request($data){
        $appid = 'wxfcd0299fb171b16c';
        $mch_id = '1375397102';//商户号
        $key = 'cf9cb68e058ab61a2cf33ff1fa2ded51';//商户key
        $notify_url = "https://test1.mgtvshop.com/wxnativepay";//回调地址
        $wechatAppPay = new \wechatAppPay($appid, $mch_id, $notify_url, $key);
        $params['body'] = '测试下';                       //商品描述
        $params['out_trade_no'] = $data['oid'];    //自定义的订单号
        $params['total_fee'] = '1';                       //订单金额 只能为整数 单位为分
        $params['trade_type'] = 'MWEB';                   //交易类型 JSAPI | NATIVE | APP | WAP 
        $params['scene_info'] = '{"h5_info": {"type":"Wap","wap_url": "https://test1.mgtvshop.com","wap_name": "测试下"}}';
        $result = $wechatAppPay->unifiedOrder( $params );
        $url = $result['mweb_url'].'&redirect_url=https%3A%2F%2Ftest1.mgtvshop.com
';//redirect_url 是支付完成后返回的页面
        return $url;
    }
}